//
//  UINavigationBar+GradientColor.m
//  Stock_Stategy
//
//  Created by MayerF on 2017/9/6.
//  Copyright © 2017年 MayerF. All rights reserved.
//

#import "UINavigationBar+GradientColor.h"

@implementation UINavigationBar (GradientColor)

- (void)initColor
{
    [self setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    [self setShadowImage:[UIImage new]];
    self.translucent = YES;
}
- (void)startGradientColor:(UIColor *)color offset:(CGFloat)offset value:(CGFloat)value
{
    CGFloat alphaValue = 0.0;
    if (offset <= value && offset > 0) {
        alphaValue = offset / value;
    }else if (offset <= 0) {
        alphaValue = 0;
    }else {
        alphaValue = 1;
    }
    self.subviews[0].backgroundColor = color;
    self.subviews[0].alpha = alphaValue;
}
- (void)resetNav
{
//    [self setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
//    [self setShadowImage:nil];
    self.subviews[0].backgroundColor = nil;
    self.subviews[0].alpha = 1.0;
}

@end
